<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Logging Action | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'actions-logging.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/actions-logging.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/actions-logging.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/actions-logging.html" rel="nofollow" target="_blank">../en/actions-logging.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="xpack-alerting.html">Alerting on cluster and index events</a></span>
»
<span class="breadcrumb-link"><a href="actions.html">Actions</a></span>
»
<span class="breadcrumb-node">Logging Action</span>
</div>
<div class="navheader">
<span class="prev">
<a href="actions-index.html">« Index action</a>
</span>
<span class="next">
<a href="actions-slack.html">Slack Action »</a>
</span>
</div>
<div class="section xpack">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="actions-logging"></a>Logging Action<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/x-pack/docs/en/watcher/actions/logging.asciidoc">edit</a><a class="xpack_tag" href="https://www.elastic.co/subscriptions"></a>
</h2>
</div></div></div>
<p>Use the <code class="literal">logging</code> action to log text to the standard Elasticsearch
logs. See <a class="xref" href="actions-logging.html#logging-action-attributes" title="Logging action attributes">Logging action attributes</a> for the supported attributes.</p>
<p>This action is primarily used during development and for debugging purposes.</p>
<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="configuring-logging-actions"></a>Configuring logging actions<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/x-pack/docs/en/watcher/actions/logging.asciidoc">edit</a>
</h3>
</div></div></div>
<p>You configure logging actions in the <code class="literal">actions</code> array. Action-specific attributes
are specified using the <code class="literal">logging</code> keyword.</p>
<p>The following snippet shows a simple logging action definition:</p>
<div class="pre_wrapper lang-js">
<pre class="programlisting prettyprint lang-js">"actions" : {
  "log" : { <a id="CO527-1"></a><i class="conum" data-value="1"></i>
    "transform" : { ... }, <a id="CO527-2"></a><i class="conum" data-value="2"></i>
    "logging" : {
      "text" : "executed at {{ctx.execution_time}}" <a id="CO527-3"></a><i class="conum" data-value="3"></i>
    }
  }
}</pre>
</div>
<div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO527-1"><i class="conum" data-value="1"></i></a></p>
</td>
<td align="left" valign="top">
<p>The id of the action.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO527-2"><i class="conum" data-value="2"></i></a></p>
</td>
<td align="left" valign="top">
<p>An optional <a class="xref" href="transform.html" title="Payload transforms">transform</a> to transform the payload before
executing the <code class="literal">logging</code> action.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO527-3"><i class="conum" data-value="3"></i></a></p>
</td>
<td align="left" valign="top">
<p>The text to be logged.</p>
</td>
</tr>
</table>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="logging-action-attributes"></a>Logging action attributes<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/x-pack/docs/en/watcher/actions/logging.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="informaltable">
<table border="1" cellpadding="4px">
<colgroup>
<col class="col_1">
<col class="col_2">
<col class="col_3">
<col class="col_4">
</colgroup>
<thead>
<tr>
<th align="left" valign="top">Name</th>
<th align="left" valign="top">Required</th>
<th align="left" valign="top">Default</th>
<th align="left" valign="top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left" valign="top"><p><code class="literal">text</code></p></td>
<td align="left" valign="top"><p>yes</p></td>
<td align="left" valign="top"><p>-</p></td>
<td align="left" valign="top"><p>The text that should be logged. Can be static text or
                                                          include Mustache <a class="xref" href="how-watcher-works.html#templates" title="Using templates">templates</a>.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">category</code></p></td>
<td align="left" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>xpack.watcher.actions.logging</p></td>
<td align="left" valign="top"><p>The category under which the text will be logged.</p></td>
</tr>
<tr>
<td align="left" valign="top"><p><code class="literal">level</code></p></td>
<td align="left" valign="top"><p>no</p></td>
<td align="left" valign="top"><p>info</p></td>
<td align="left" valign="top"><p>The logging level. Valid values are: <code class="literal">error</code>, <code class="literal">warn</code>,
                                                          <code class="literal">info</code>, <code class="literal">debug</code> and <code class="literal">trace</code>.</p></td>
</tr>
</tbody>
</table>
</div>
</div>

</div>
<div class="navfooter">
<span class="prev">
<a href="actions-index.html">« Index action</a>
</span>
<span class="next">
<a href="actions-slack.html">Slack Action »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>